﻿using RabbitMq.core.Service;
using RabbitMQ.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Commom.Utils;

namespace Send
{
    class Program
    {
        static void Main(string[] args)
        {

            RabbitMq.core.Utils.RabbitMqConfig config = new RabbitMq.core.Utils.RabbitMqConfig();
            config.AmqpLists = new List<RabbitMQ.Client.AmqpTcpEndpoint>() { new AmqpTcpEndpoint(new Uri("amqp://192.168.10.244:5672")) };
            config.UserName = "superrd";
            config.Password = "superrd";
            config.VirtualHost = "/";
            config.ExchangeName = "touchExchange";
            config.RoutingKey = "touchRoutingKey";
            config.ExchangeType = RabbitMq.core.Utils.ExchangeTypeEnum.direct;
            config.DurableMessage = true;

           

            //BaseService mqService = new BaseService();
            //mqService.RabbitConfig = config;
            //string errMsg = "";
            while (true)
            {
                RPCClientService client = new RPCClientService(config);
                Task<string> t = client.SendMsg(Console.ReadLine());
                t.Wait();
                MQRespone res = t.Result.ToString().ToObject<MQRespone>();
                Console.WriteLine(string.Format("预定状态:{0},预定消息:{1},预定序列号:{2}", res.ResponeStatusEnum, res.Body.message, res.SerialNumber));
                client.Close();
                //string message = string.Format("Message_{0}", Console.ReadLine());
                //Task<string> t = mqService.Send1(message, true, ref errMsg);
                //t.Wait();
                //Console.WriteLine($"[x1]: {t.Result}");
                //mqService.connection.Close();
            }


        }
    }
}
